package rwt.server.handlers.web;

import rwt.server.WebMessages.OpenSwitchesRequest;
import rwt.server.core.*;
import rwt.server.railroad.Switches;

public class OpenSwitchRequestHandler extends MessageHandler<OpenSwitchesRequest>
{
	@Override
	public void handle(OpenSwitchesRequest message, IConnection source) throws Exception
	{
		if (!(source instanceof IClient))
			throw new IllegalArgumentException("OpenSwitchRequest did not come from a client.");
		
		IClient client = (IClient) source;
		Switches.getInstance().addClientSwitches(client, message.isEmergency, message.switchType);
	}
}
